<template>
  <div class="ggSon">
    <div class="w-100 ib">ggSon</div>
    <el-select @change="getggSon" v-model="value" placeholder="ggSon data">
      <el-option
        v-for="item in ggSonOptions"
        :key="item.value"
        :label="item.label"
        :value="item.value">
      </el-option>
    </el-select>
  </div>
</template>
 
<script>
export default {
  name: '',
  inject: {
    selectValue: {
      //函数式组件取值不一样
      default: () => ({})
    }
  },
  // inject: ['selectValue'],
  props: {
    ggSonOptions: Array
  },
  data () {
    return {
      // value: '选项1'
      // selectValue => 法1  selectValue.value => 法2
      // value: this.selectValue
      value: this.selectValue.pvalue
    }
  },
  watch: {
    // selectValue(n, o) {
    //   console.log(n, o)
    //   this.value = n
    // },
    'selectValue.pvalue': function(n, o) {
      this.value = n
    }
  },
  mounted() {
    // console.log(this.selectValue)
    // this.value = this.selectValue.pvalue
  },
  methods: {
    getggSon(v) {
      console.log('ggSon', v)
      this.$emit('getggSon', v)
    },
  }
}
</script>
 
<style scoped lang="scss">
 
</style>